extends CardState

const MOUSE_Y_SNAPBACK_THRESHOLD := 138

func enter() -> void:
	card_ui.targets.clear()
	var offset := Vector2(card_ui.parent.size.x/2, -card_ui.parent.size.y/2)
	offset.x -= card_ui.size.x / 2
	card_ui.animate_to_position(card_ui.parent.global_position + offset, 0.2)
	card_ui.drop_point_dector.monitoring = false
	Events.do_card_aim_started(card_ui)
	
	
func exit() -> void:
	Events.do_card_aim_ended(card_ui)
	Events.do_tooltip_hide()
	
func on_input(event:  InputEvent) -> void:
	var mouse_motion := event is InputEventMouseButton
	var mouse_at_bottom := card_ui.get_global_mouse_position().y > MOUSE_Y_SNAPBACK_THRESHOLD
	if (mouse_at_bottom and mouse_motion) or event.is_action_pressed("right_mouse"):
		card_ui.targets.clear()
		do_transition(self, CardState.State.BASE)
	elif event.is_action_released("left_mouse") or event.is_action_pressed("left_mouse"):
		get_viewport().set_input_as_handled()
		do_transition(self, CardState.State.RELEASED)
		
